package coroutines.exception

import kotlinx.coroutines.*
import java.lang.Exception

class CoroutineExceptionTest6 {
}

fun main() {
    runBlocking {
        val scope = CoroutineScope(Job())
        scope.launch {
            val syncA = async(SupervisorJob() + CoroutineExceptionHandler { _, _ -> }) {
                println("asyncA 抛出异常")
                throw Exception("asyncA 抛出的异常")
            }

            val syncB = async(SupervisorJob() + CoroutineExceptionHandler { _, _ -> }) {
                println("asyncB 抛出异常")
                throw Exception("asyncB 抛出的异常")
            }

            kotlin.runCatching {
                syncA.await()
                syncB.await()
            }
        }

        delay(1000)
    }
}